package com.ishell.generate.bean;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 作者: crazier.huang
 * 项目: generate
 * 日期: 2018/6/9 星期六
 * 说明:
 */
public enum DataTypeEnum {
    BIGINT("bigint",Integer.class),
    INT("int",Integer.class),
    VARCHAR("varchar",String.class),
    DATETIME("datetime",Date.class),
    DECIMAL("decimal",BigDecimal.class),
    LONGTEXT("longtext",String.class),
    BIT("bit",Boolean.class),
    BLOB("blob",String.class),
    TINYINT("tinyint",Integer.class),
    TEXT("text",Integer.class),
    DATE("date",Date.class),
    DOUBLE("double",Double.class),
    FLOAT("float",Float.class),

    ORACLE_NUMBER("NUMBER",Integer.class),
    ORACLE_VARCHAR("VARCHAR2",String.class),
    ORACLE_DATE("DATE",Date.class)
    ;

    private String columnType;
    private Class clazz;

    DataTypeEnum(String columnType, Class clazz) {
        this.columnType = columnType;
        this.clazz = clazz;
    }
    public static Class parseByType(String columnType) {
        for (DataTypeEnum type : DataTypeEnum.values()) {
            if (type.getColumnType().equals(columnType)) {
                return type.clazz;
            }
        }
        return null;
    }

    public String getColumnType() {
        return columnType;
    }

    public Class getClazz() {
        return clazz;
    }
}
